package com.zhny.aiot.gateway.plugin;

import com.zhny.aiot.gateway.plugin.device.GatewayDevice;
import com.zhny.aiot.gateway.plugin.model.GatewayStoreEntry;
import com.zhny.aiot.plugin.ICenterFacilities;
import com.zhny.aiot.plugin.IDevice;
import com.zhny.aiot.plugin.model.CommandEntry;
import com.zhny.aiot.plugin.model.DeviceEntity;
import com.zhny.aiot.plugin.model.FactoryType;
import com.zhny.aiot.plugin.model.StoreEntity;
import com.zhny.aiot.plugin.zhnygateway.GatewayServer;
import com.zhny.aiot.plugin.zhnygateway.device.ZhnyDeviceFactory;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;

import java.util.ArrayList;
import java.util.List;

public class GatewayPlugin extends Plugin {
    public GatewayPlugin(PluginWrapper wrapper) {
        super(wrapper);
    }

    @Extension
    public static class GatewayFactory extends ZhnyDeviceFactory<GatewayStoreEntry> {

        @Override
        public List<CommandEntry> supportCommandClasses() {
            List<CommandEntry> commands =  new ArrayList();
            commands.add(CommandEntry.valueOf("reboot", "重启", "无参数",null));
            return commands;
        }

        public IDevice createDevice(ICenterFacilities iCenterFacilities, DeviceEntity entity) {
            return new GatewayDevice(GatewayServer.getInstance ().getEngine () ,this,iCenterFacilities,entity);
        }

        public Class<? extends StoreEntity> storeClass() {
            return GatewayStoreEntry.class;
        }

        public String getId() {
            return "zhny-gateway-plugin";
        }

        public String getName() {
            return "智慧农业网关插件";
        }

        public FactoryType getType() {
            return FactoryType.Gateway;
        }


    }
}
